<?php include_once("header.html")?>

<div id="wrap">  <br />
	<?php include_once("home_left.html")?>
    <div class="admincontent">
		<?php include_once("home_assignmenttop.html")?>
		
<script src="<?php echo $www_site_url?>/public/js/common.js" type="text/javascript"></script>
<script src="<?php echo $www_site_url?>/public/js/vote.js" type="text/javascript"></script>
<script>

function checkform(form){
	var g=function(n){
		return form.getElementsByTagName(n);
	};
	var va=function(e){
		if(e.name) return encodeURIComponent(e.value);
	};
	var check=function(r){
		for(var i=0;i<r.length;i++){
			if(r[i].checked) return true;
		}
		return false;
	}
	var result = true;
	
	var input = g('input');
	for(var i=0;i<input.length;i++){
		var v = va(input[i]);
		if(input[i].type=='text' || input[i].type=='hidden'){
			if( v==''){
				input[i].parentNode.style.border='1px solid red';
				result=false;
			}else{
				input[i].parentNode.style.border='';
			}
		} 
		if(input[i].type=='radio'){
			if(check(form.elements[input[i].name])){
				input[i].parentNode.style.border='';
			}else{
				input[i].parentNode.style.border='1px solid red';
			}
		}
	}
	
	var textarea = g('textarea');
	for(var i=0;i<textarea.length;i++){
		var v=va(textarea[i]);
		if(textarea[i].name.indexOf("rq_comment_")!=-1) continue;
		if(v==''){
			textarea[i].style.border='1px solid red';
			result=false;
		}else{
			textarea[i].style.border='';
		}
	}
	if(!result) alert("<?php echo lang("fiinish_redmark_question")?>");
	if(result && confirm("<?php echo lang("submit_alert");?>")){
		return result;
	}else{
		return false;
	}
	

}
	
	
</script>

	<?php if($is_view && $assignmentinfo['a_quiz_pass']>0){
		if($is_submitted==0 || $is_submitted==2){
			
			if($is_submitted==2){
				echo ' <p>&nbsp;</p><div align="center">'.lang("approval_notpass")."</div>";
			}
		if(isset($report_questions) && is_array($report_questions)){?>
			<br /><br />
				 <br />
		    <p><?php echo lang("grade_info")?>：</p>
			<table width="100%" border="0" cellpadding="0" cellspacing="1" class="missionReport" class="clear">
          <tr>
            <td class="title"><?php echo lang("level_0")?></td>
            <td class="title"><?php echo lang("level_1")?></td>
            <td class="title"><?php echo lang("level_2")?></td>
            <td class="title"><?php echo lang("level_3")?></td>
            <td class="title"><?php echo lang("level_4")?></td>
            <td class="title"><?php echo lang("level_5")?></td>
            <td class="title"><?php echo lang("level_6")?></td>
            <td class="title"><?php echo lang("level_7")?></td>
          </tr> 
          <tr>
            <td align="center">n/a</td>
            <td align="center">0</td>
            <td align="center">1-2</td>
            <td align="center">3-4</td>
            <td align="center">5</td>
            <td align="center">6-7</td>
            <td align="center">8-9</td>
            <td align="center">10</td>
          </tr>
       
          </table>
         
         <form action="<?php echo $www_site_url?>/index.php" method="post" onsubmit="return checkform(this);">
				<input type="hidden" name="action" value="home">
				<input type="hidden" name="op" value="savereport">
				<input type="hidden" name="a_id" value="<?php echo $a_id;?>">
       <?php
		foreach ($report_questions as $k=>$v){?>
		<table width="100%" border="0" cellpadding="0" cellspacing="1" class="missionReport" style="margin-top:10px;">
          <tr>
            <td colspan="3" class="title"><?php echo lang($k);?></td>
          </tr>
          <?php
			foreach ($v as $kk=>$vv){
				if($vv['rq_type']==2 || $vv['rq_type']==4 || $vv['rq_type']==1){
				?>
          <tr>
			 <td width="5%"><?php echo $GLOBALS['gGroupsCap'][$k]. "".($kk+1)?></td>
            <td width="60%"><?php echo splitx($vv['rq_question']);?> <span id="span_ch_<?php echo $vv['rq_id'];?>" style="float:right;"></span></td>
            <td  width="35%" align="center">
             <?php if($vv['rq_type']==2){?>
            	<?php if($vv['is_na']==1){?> <span style="float:left;"> <img id="icon_updown_<?php echo $vv['rq_id'];?>" style="cursor:pointer;" src="<?php echo $www_site_url?>/public/images/up_down.jpg" onclick="display_comment(<?php echo $vv['rq_id'];?>);"><input type="checkbox" id="votebox_<?php echo $vv['rq_id'];?>" name="votebox_<?php echo $vv['rq_id'];?>" onclick="out_fs('yes_<?php echo $vv['rq_id'];?>_10');"  <?php if($vv['answer']=='A') echo "checked"; ?>>N/A</span><?php }?>
            					<div id="voteimg_<?php echo $vv['rq_id'];?>"></div>	
								<input type="hidden" id="rq_ans_<?php echo $vv['rq_id'];?>" name="rq_ans_<?php echo $vv['rq_type']."_".$vv['rq_id'];?>" value="<?php echo $vv['answer'];?>">
								<script>create_vote_img(<?php echo $vv['rq_id'];?>,'<?php echo $vv['answer'];?>');</script>	
								
			<?php }else if($vv['rq_type']==1){ ?>		
								 <?php if($vv['is_na']==1){?><span> <img id="icon_updown_<?php echo $vv['rq_id'];?>" style="cursor:pointer;" src="<?php echo $www_site_url?>/public/images/up_down.jpg" onclick="display_comment(<?php echo $vv['rq_id'];?>);"><input type="radio" name="rq_ans_<?php echo $vv['rq_type']."_".$vv['rq_id'];?>" value="A" <?php if($vv['answer']=='A')echo 'checked'; ?> onclick="display_comment(<?php echo $vv['rq_id'];?>);">N/A ;<span><?php }?>
								 <input type="radio" name="rq_ans_<?php echo $vv['rq_type']."_".$vv['rq_id'];?>" value="Y" <?php if($vv['answer']=='Y')echo 'checked'; ?> onclick="display_comment(<?php echo $vv['rq_id'];?>);">Yes ;</label>&nbsp;&nbsp;&nbsp;&nbsp;<label><input onclick="display_comment(<?php echo $vv['rq_id'];?>);" type="radio" name="rq_ans_<?php echo $vv['rq_type']."_".$vv['rq_id'];?>" value="N"  <?php if($vv['answer']=='N')echo 'checked'; ?>>No;</label>
								
			<?php }else if($vv['rq_type']==4){ ?>	
								<input type="text" size="6" name="rq_ans_<?php echo $vv['rq_type']."_".$vv['rq_id'];?>" value="<?php echo $vv['answer']; ?>">	分钟
							<?php }?>
            </td>
          </tr>
           
          <?php if($vv['is_comment']==1){?>
          <tr <?php if(!$vv['comment']) echo 'style="display:none;"'?> id="td_comment_<?php echo $vv['rq_id'];?>">
          <td colspan="3" ><textarea style="width:100%;font-size:12px;height:32px;" rows="2" name="rq_comment_<?php echo $vv['rq_type']."_".$vv['rq_id'];?>" id="rq_comment_<?php echo $vv['rq_type']."_".$vv['rq_id'];?>"><?php echo $vv['comment'];?></textarea></td>
          </tr>
          <?php }?>
       		 <?php 
				}else if($vv['rq_type']==3){ 
			?>
			  <?php  
					if($vv['rq_group']==5){
					?>	
			<tr>
			 <td width="5%" valign="top"><?php echo $GLOBALS['gGroupsCap'][$k]. "".($kk+1)?></td>
			 <td width="60%"><?php echo splitx($vv['rq_question']);?></td>
            <td  width="35%" align="center"><input class="textfield" type="text" name="rq_ans_<?php echo $vv['rq_type']."_".$vv['rq_id'];?>" value="<?php echo $vv['answer']; ?>"></td>
                        
          </tr>
          <? }else{?>
			<tr>
			 <td width="5%" valign="top"><?php echo $GLOBALS['gGroupsCap'][$k]. "".($kk+1)?></td>
             <td width="95%" colspan="2" style="padding:0">
            
		            <table width="100%" border="0" cellpadding="0" cellspacing="0">
			            <tr> 
			            	<td width="50%" style="background-color:#ccc;"> <?php echo splitx($vv['rq_question'])?></td>
			            
			          	</tr>
			           <tr>
				           <td style="height:50px">
													<textarea  style="width:100%;font-size:12px;height:60px;" name="rq_ans_<?php echo $vv['rq_type']."_".$vv['rq_id'];?>"><?php echo $vv['answer']; ?></textarea>
				           </td>
			            </tr>
		             </table>
            </td>
          </tr>	
	   <?php } 
			
				}
				
			}
			?>
			
        </table>
 		<?php }?>
 		<table width="100%" height="50">
	 		<tr>
				<td align="center"><input type="submit" value="<?php echo lang('submit')?>" class="btn" /></td>
			</tr>
		</table>
		</form>
				
			

				
  <?php 	}
  
		}elseif($is_submitted==3){
			echo ' <p>&nbsp;</p> <div align="center">'.lang('finish_report')."</div>";
		}elseif($is_submitted==1){
			echo ' <p>&nbsp;</p> <div align="center">'.lang('approval_pass')."</div>";
		}
	}else{?>
   <p>&nbsp;</p>
   <p>&nbsp;</p>
   <p>&nbsp;</p>
   <div align="center"><?php echo lang("apply_second")?></div>
  <?php }?>
  
  </div>
</div>
<?php include_once("footer.html")?>
